home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7500 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: hal.COM!spike
  2. From: spike@hal.com (Spike White)
  3. Newsgroups: comp.lang.apl,comp.lang.asm.x86,comp.lang.c,comp.lang.c++,comp.os.ms-windows.programmer.networks
  4. Subject: Re: API Call to Acquire Ethernet Address
  5. Date: 23 Feb 1996 17:11:05 GMT
  6. Organization: HAL Computer Systems, Inc.
  7. Message-ID: <4gksf9$jgl@news.hal.com>
  8. References: <4f0bml$lvd@noc.tor.hookup.net> <4fnm1j$52@ns2.emirates.net.ae> <4gi2fg$bcq@news.hal.com>
  9. NNTP-Posting-Host: zarathustra.hal.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Spike White (spike@hal.com) wrote:
  13. : Kannan (kannan@emirates.net.ae) wrote:
  14. : : patrick@xiris.com (Patrick Whittle) wrote:
  15.  
  16. : : >I need access to an API call that will return the
  17. : : >ethernet address from a NIC.  Many programs and
  18. : : >utilities I have used display the ethernet address 
  19. : : >such as "arp -a" from the TCP/IP protocol siute.
  20.  
  21. : : I too am interested in such a API call. please post it in this ng.
  22.  
  23. : Good luck!  I had to write such a function on various UNIX system we
  24. : ported to.  I was hoping for something analogous to 
  25. : gethostname()/gethostaddr(), but no such luck.  Which is weird, because
  26. : I see a ether_ntoa() which is analogous to inet_ntoa().
  27.  
  28. : Altogether, it's about 400 lines of code since it must be done different
  29. : ways on different platforms.  For platforms that support a DLPI interface
  30. : to the ethernet h/w, it's reasonably portable.   But quite low-level --
  31. : putting and getting STREAMS msgs.
  32.  
  33. Someone wrote and gave me a clue for a *much* easier way to portably do
  34. it on any UNIX system.  Do an 'arp -a' and parse the output, looking for
  35. your hostname.  You can use gethostname() to get your hostname.  You can only 
  36. do 'arp' as root.
  37.  
  38. It's been awhile since I've done any TCP/IP on a PC, but I seem to recall
  39. there was an 'arp' command there also.
  40.  
  41. Spike
  42.  
  43. --
  44. Spike White          | spike@hal.com               | Biker Nerds
  45. HaL Software Systems | '87 BMW K75S, DoD #1347     |  From  HaL
  46. Austin, TX           |  http://www.halsoft.com/users/spike/index.html 
  47. Disclaimer:  HaL, want me to speak for you?  No, Dave... 
  48.